//
//  PPImageDisplayViewController.m
//  PetParadise
//
//  Created by 陈无忌 on 9/1/14.
//  Copyright (c) 2014 whalefin. All rights reserved.
//

#import "PPImageDisplayViewController.h"
#import "TTScrollableAds.h"

@interface PPImageDisplayViewController ()<UIGestureRecognizerDelegate>
@property (weak, nonatomic) IBOutlet TTScrollableAds *myImageAds;
@property (strong, nonatomic) NSMutableArray *imageArray;
@property (nonatomic) BOOL isNavHidden;


@end

@implementation PPImageDisplayViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    //隐藏navigation Bar
    self.isNavHidden = YES;
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.myImageAds.index = self.index;
    self.imageArray=[[NSMutableArray alloc]init];
    if (self.topic.topicImgList.count>0) {
        for (int i = 0; i < self.topic.topicImgList.count; i++) {
            PPTopicImage *img = [self.topic.topicImgList objectAtIndex:i];
            [self.imageArray addObject:[PPImageUrl getImageUrlOriginal:img.img]];
        }
        self.myImageAds.imageArray = self.imageArray;
    }
    if (self.pet.petImgList.count > 0) {
        for (int i = 0; i < self.pet.petImgList.count; i++) {
            PPPetPhoto *img = [self.pet.petImgList objectAtIndex:i];
            [self.imageArray addObject:[PPImageUrl getImageUrlOriginal:img.img]];
        }
        self.myImageAds.imageArray = self.imageArray;
    }
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewCallBack) name:@"viewCallBack" object:nil];
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(navigationHide) name:@"navigationHide" object:nil];
    // Do any additional setup after loading the view.
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)viewCallBack
{
    [self.navigationController popViewControllerAnimated:YES];
}

//-(void)navigationShow
//{
//    if (self.isNavHidden) {
//        [self.navigationController setNavigationBarHidden:NO animated:YES];
//        self.isNavHidden = NO;
//    }else{
//        [self navigationHide];
//    }
//}
//
//-(void)navigationHide
//{
//    [self.navigationController setNavigationBarHidden:YES animated:YES];
//    self.isNavHidden = YES;
//}

- (IBAction)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
